package com.yanqu.data.analytics.helper;

import com.yanqu.data.analytics.enums.eUserIdAttr;

import java.util.HashMap;
import java.util.Map;

public class DataBuilder {

    String accountId;

    String distinctId;

    Map<String, Object> dataMap = new HashMap<>();

    public static DataBuilder newBuilder(String accountId, String distinctId){
        DataBuilder dataBuilder = new DataBuilder();
        dataBuilder.setAccountId(accountId);
        dataBuilder.setDistinctId(distinctId);
        dataBuilder.build(eUserIdAttr.ACCOUNT_ID.getAttrId(), accountId).build(eUserIdAttr.DISTINCT_ID.getAttrId(), distinctId);
        return dataBuilder;
    }

    public static DataBuilder newBuilder(long userId, String distinctId){
        return newBuilder(userId + "", distinctId);
    }

    public String getAccountId() {
        return accountId;
    }

    public void setAccountId(String accountId) {
        this.accountId = accountId;
    }

    public String getDistinctId() {
        return distinctId;
    }

    public void setDistinctId(String distinctId) {
        this.distinctId = distinctId;
    }

    public Map<String, Object> getDataMap() {
        return dataMap;
    }

    public DataBuilder build(String key, Object val){
        if(key == null || val == null){
            return this;
        }
        dataMap.put(key, val);
        return this;
    }
}
